def spam(a, b, c, d):
    print(a, b, c, d)


from functools import partial

s1 = partial(spam, 1)  # a = 1
s1(2, 3, 4)
s3 = partial(spam, 1, 2, d=42)  # a = 1, b = 2, d = 42

points = [(1, 2), (3, 4), (5, 6), (7, 8)]

import math


def distance(p1, p2):
    x1, y1 = p1
    x2, y2 = p2
    return math.hypot(x2 - x1, y2 - y1)


pt = (4, 3)
points.sort(key=partial(distance, pt))
print(points)


def outs_result(result, log=None):
    if log is not None:
        log.debug('Got:%r', result)


# A sample function
def add(x, y):
    return x + y


if __name__ == '__main__':
    print('-' * 50)
    import logging
    from multiprocessing import Pool
    from functools import partial

    logging.basicConfig(level=logging.DEBUG)
    log = logging.getLogger('test')

    p = Pool()
    p.apply_async(add, (3, 4), callback=partial(outs_result, log=log))
    p.close()
    p.join()
